package main.test;

import main.http.HttpHandler;
import main.http.HttpRequest;
import main.http.HttpResponse;

/**
 * Created by hdt3213 on 17/3/27.
 */

public class SimpleHttpHandler extends HttpHandler {

	@Override
	public void setup() {
		// invoke this method before handle request

	}

	@Override
	public void clean() {
		// invoke this method after send response
	}

	@Override
	public HttpResponse handle(HttpRequest request) {
		switch (request.getPath()) {
			case "/":
				return handleRoot(request);
			case "/cookie":
				return handleCookie(request);
			default:
				return new HttpResponse("<p>404</p>");
		}
	}

	HttpResponse handleRoot(HttpRequest request) {
		return new HttpResponse("<p>Hello</p>");
	}

	HttpResponse handleCookie(HttpRequest request) {
		HttpResponse response = new HttpResponse("<p>Hello</p>");
		response.setCookie("a", "1");
//		System.out.print(response.getTxt());
		return response;
	}

}
